<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

    <body>
        <ui:composition template="../templates/default3.xhtml">  



            <ui:define name="content">
                <h:form binding="#{salesOrderManagerBean.loadViewPurchaseOrderPage}">
                    <p:panel header="View Purchase Order" id="purchaseOrderPanel">
                        <p:messages/>
                        <table class="panel">
                            <tr>
                                <td width ="30px">Company:</td>
                                <td width="200px"> <h:outputText id ="company" value="#{salesOrderManagerBean.selectedPurchaseOrder.customer.company}"  />  
                                </td>
                            </tr>
                            <tr>
                                <td>Company Address:</td>
                                <td><h:outputText id ="address" value="#{salesOrderManagerBean.selectedPurchaseOrder.customer.companyAddress.street}, 
                                                  #{salesOrderManagerBean.selectedPurchaseOrder.customer.companyAddress.country}, #{salesOrderManagerBean.selectedPurchaseOrder.customer.companyAddress.postal}             " /> </td>
                            </tr>
                            <tr>
                                <td>Purchase Order No.:</td>
                                <td><h:outputText  id="poNumber" value="#{salesOrderManagerBean.selectedPurchaseOrder.poNumber}" />

                                </td>

                            </tr>
                            <tr>
                                <td>Purchase Order Date:</td>
                                <td>
                                    <h:outputText value="#{salesOrderManagerBean.selectedPurchaseOrder.poDate}">  
                                        <f:convertDateTime pattern="dd-MM-yyyy" timeZone="#{defaultManagerBean.tz}"/>
                                    </h:outputText>
                                </td>
                            </tr>

                            <tr>
                                <td>Remark:</td>
                                <td><h:outputText id="remark" value="#{salesOrderManagerBean.selectedPurchaseOrder.remark}" />  

                                </td>                               
                            </tr>

                            <tr>
                                <td>Billing Address:</td>
                                <td><h:outputText id="billingAddress" value="#{salesOrderManagerBean.selectedPurchaseOrder.billingAddress.street},
                                                  #{salesOrderManagerBean.selectedPurchaseOrder.billingAddress.country},
                                                  #{salesOrderManagerBean.selectedPurchaseOrder.billingAddress.postal}" />  

                                </td>                               
                            </tr> 
                            <tr>
                                <td>Total Amount:</td>
                                <td><h:outputText id="totalAmount" value="#{salesOrderManagerBean.selectedPurchaseOrder.totalAmount}" />  

                                </td>                               
                            </tr> 
                            <tr>
                                <td>Credit Rate:</td>
                                <td><h:outputText id="creditRate" value="#{salesOrderManagerBean.selectedPurchaseOrder.creditRate}" />  

                                </td>                               
                            </tr> 
                            <tr>
                                <td>First Payment:</td>
                                <td><h:outputText id="firstPayment" value="#{salesOrderManagerBean.selectedPurchaseOrder.firstPayment}" />  

                                </td>                               
                            </tr> 
                        </table>
                    </p:panel>
                    <p:panel header="Order items" id="viewPurchaseOrderItems">


                        <p:dataTable id="purchaseItem" var="purchaseItem" value="#{salesOrderManagerBean.selectedPurchaseOrder.purchaseItems}" paginator="false"                                     
                                     emptyMessage="No item found with given criteria.">                                                             

                            <p:column headerText="Product name"> 
                                <h:outputText value="#{purchaseItem.product.name}" />                                             
                            </p:column> 
                            <p:column headerText="Quantity"> 
                                <h:outputText value="#{purchaseItem.quantity}" />                                             
                            </p:column> 
                            <p:column headerText="Unit price"> 
                                <h:outputText value="#{purchaseItem.unitPrice}" />                                             
                            </p:column>      
                            <p:column headerText="Shipping rate"> 
                                <h:outputText value="#{purchaseItem.shippingRate}" />                                             
                            </p:column>      
                            <p:column headerText="Discount"> 
                                <h:outputText value="#{purchaseItem.discount}" />                                             
                            </p:column> 
                            <p:column headerText="Sub Total"> 
                                <h:outputText value="#{purchaseItem.subTotal}" />                                             
                            </p:column>     
                            <p:column headerText="Shipping"> 
                                <h:outputText value="#{purchaseItem.shippingAddress.street}, #{purchaseItem.shippingAddress.city}" />                                             
                            </p:column>     

                        </p:dataTable>                        

                    </p:panel>
                    <table class="panel">
                        <tr>
                            <td class="btn">
                                <p:commandButton id="btnBackToPurchaseOrders" value="Back" actionListener="#{salesOrderManagerBean.back}" 
                                                 update="purchaseOrderPanel" ajax="true" />
                            </td>
                        </tr>
                    </table>
                </h:form>
            </ui:define>



        </ui:composition>


    </body>
</html>
